﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

using System.IO;
//using System.Drawing;
//using System.Drawing.Imaging;
//using System.Configuration;
using System.Threading;

namespace FileOperationWinform
{
    static class Program
    {

        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool createNew;
            Mutex mutex = new Mutex(true, "Form1", out createNew);
            if (!createNew)
            {
                return;
                MessageBox.Show("本系统已经启动！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                string path = Application.StartupPath + @"\";
                string Filehelp = "FileOpeationHelp.chm";
                FileOperationWinform.FileResourceAuto x = new FileOperationWinform.FileResourceAuto();
                x.FileConfigureAuto();
                x.FileAuto(Filehelp, 0);
                string dllFileName = "IrisSkin2.dll";
                x.FileAuto(dllFileName, 1);
                string dllFileName1 = "ZedGraph.dll";
                x.FileAuto(dllFileName1, 2);

                
                string skimsn = "MSN.ssk";
                string skin1 = "vista1.ssk";
                string skin2 = "SportsBlack.ssk";
                string skin3 = "Eighteen.ssk";
                string skin4 = "Emerald.ssk";
                string storefolder = path + @"\Skin" + @"\";
                DirectoryInfo di = new DirectoryInfo("" + storefolder);
                if (!di.Exists)
                    di.Create();
                string t = @"\Skin\" + skimsn;
                x.FileAuto(t, 3);
                string t1 = @"\Skin\" + skin1;
                x.FileAuto(t1, 4);
                string t2 = @"\Skin\" + skin2;
                x.FileAuto(t2, 5);
                string t3 = @"\Skin\" + skin3;
                x.FileAuto(t3, 6);
                string t4 = @"\Skin\" + skin4;
                x.FileAuto(t4, 7);
                x = null;
                #region     将bitmap转换为buffer
                //string skinpp = "Emerald.ssk";
                //if (!File.Exists(path + @"\Skin\" + skinpp))   //文件不存在
                //{
                //    FileStream fs6 = new FileStream(path + @"\Skin\" + skinpp, FileMode.CreateNew, FileAccess.Write);
                //    MemoryStream ms5 = new MemoryStream();
                //    FileOperationWinform.Properties.Resources.emerald_color3.Save(ms5, ImageFormat.Png);
                //    byte[] buffer6 = ms5.ToArray();//{GetData是命名空间}
                //    fs6.Write(buffer6, 0, buffer6.Length);
                //    fs6.Close();
                //}
                #endregion
                Application.Run(new FormMain());
                mutex.ReleaseMutex();
            }
        }
    }
}
